Performance tuning

The following are tips and tricks to squeeze the most performance out of Webwork.

Turn off logging and devMode

DevMode allows reloading of configuration and validation related files, but because they happen on each request, this setting will totally kill your performance.
When using logging, make sure to turn off logging (esp. Freemarker generates a LOT of logging), and check if a level is enabled before printing it, or you will get the cost of the String parsing/concatination anyways.

Do not use interceptors you do not need

If you do not require a full stack of interceptors for an Action, then try using a different one (basicStack), or remove interceptors you do not need.

Use the correct http headers (Cache-Control & Expires)

When returning HTML views, make sure to add the correct headers so browsers knows how to cache them.

Copy the static content from the webwork jar when using the Ajax theme (Dojo) or the Calendar tag

WebWork uses some external javascript libraries and cascading stylesheets for certain themes and tags. These by default are located inside the webwork jar, and a special filter returns them when requesting a special path (/webwork).
Copy the .css and .js files to another directory in your WEB_APP root or even better: use a seperate server for this (lighttpd, apache, ..).

Create a freemarker.properties file in your WEB-INF/classes directory

Create the freemarker.properties file and add the following setting (or whatever value you deem fitting):

template_update_delay=60000

This value determines how often freemarker checks if it needs to reloads the templates from disk. The default value is 500 ms. Since there is no reason to check if a template needs reloading, it is best to set this to a very large value. Note that this value is in seconds and freemarker will convert this value to milliseconds.

See also: Freemarker configuration properties

Copy the /template directory from the webwork jar in your WEB_APP root.

Freemarker fails to properly cache templates when they are retrieved from the classpath. Copying them to the WEB_APP root allows Freemarker to cache them correctly. Freemarker looks at the last modified time of the template to determine if it needs to reload the templates. Resources retrieved from the classpath have no last modified time, so Freemarker will reload them on every request.

When overriding a theme, copy all necessary templates to the theme directory

There's a performance cost when a template cannot be found in the current directory. The reason for this is that Webwork must check for a template in the current theme first before falling back to the parent theme. In the future, this penalty could be eliminated by implementing a missing template cache in Webwork. (Patches would be welcome)

Do not create sessions unless you need them

WebWork does not create sessions unless you ask it to. Note that when you use SiteMesh however, a session will always be created. (See http://forums.opensymphony.com/thread.jspa?messageID=5688 for details)

When using FreemarkerResult, try to use the Freemarker equivalent rather than using the JSP tags

Freemarker has support for iterating lists, displaying properties, including files, macro's, etc ...